package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.os.Handler;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.TypefaceSpan;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appmarket.service.appdetail.bean.detail.CondictionBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailVanAttendcardBean;
import com.huawei.appmarket.service.reserve.game.bean.ReserveResponse;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import huawei.widget.HwButton;
import java.util.List;
import o.azb;
import o.cgz;
import o.ckl;
import o.BaseRequest;
import o.dgh;
import o.Logger;
import o.doo;
import o.efb;
import o.efc;
import o.efe;
import o.eit;
import o.emz;
import o.eod;
import o.CollectCheck;
import o.NetWorkUtil;
import o.evk;
import o.ewm.c;
import o.ewm.j;
import o.ewm.n;

public class DetailVanAttendGeneralCard extends BaseDistCard implements OnClickListener, efe {
    private Context ʻ;
    private HwButton ʻॱ;
    private LinearLayout ʼ;
    private View ʽ;
    private ImageView ˊॱ;
    private View ˋ;
    private int ˋˋ = 0;
    private ImageView ˋॱ;
    private CondictionBean ˋᐝ;
    private int ˌ = 0;
    private CondictionBean ˍ;
    private boolean ˎˎ = false;
    private TextView ˎˏ;
    private TextView ˏˎ;
    private View ˏˏ;
    private ImageView ˏॱ;
    private View ˑ;
    private ImageView ͺ;
    private Handler ͺॱ = new Handler();
    private ImageView ॱˊ;
    private DetailVanAttendcardBean ॱˋ;
    private HwButton ॱˎ;
    private TextView ॱͺ;
    private View ॱॱ;
    private CondictionBean ॱᐝ;
    private View ᐝ;
    private ImageView ᐝॱ;

    class a implements Runnable {
        final /* synthetic */ DetailVanAttendGeneralCard ˏ;

        private a(DetailVanAttendGeneralCard detailVanAttendGeneralCard) {
            this.ˏ = detailVanAttendGeneralCard;
        }

        public void run() {
            Logger.ˎ("DetailVanAttendGeneralCard", "RefreshQuestionRunnable");
            this.ˏ.ˊ(1);
        }
    }

    class e implements Runnable {
        final /* synthetic */ DetailVanAttendGeneralCard ˏ;

        private e(DetailVanAttendGeneralCard detailVanAttendGeneralCard) {
            this.ˏ = detailVanAttendGeneralCard;
        }

        public void run() {
            Logger.ˎ("DetailVanAttendGeneralCard", "RefreshOrderRunnable");
            this.ˏ.ˎ(1);
        }
    }

    public /* synthetic */ cgz ˏ(View view) {
        return ˎ(view);
    }

    public DetailVanAttendGeneralCard(Context context) {
        super(context);
    }

    public DetailVanAttendGeneralCard ˎ(View view) {
        this.ˋ = view;
        this.ʻ = this.ˋ.getContext();
        azb.ˏ(view, j.ʾꜟ);
        azb.ˏ(view, j.ʹᐝ);
        ˎ();
        ˊ();
        ॱॱ();
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        if (cardBean instanceof DetailVanAttendcardBean) {
            this.ॱˋ = (DetailVanAttendcardBean) cardBean;
            this.ˌ = this.ॱˋ.ꓸ();
            if (CollectCheck.isEmpty(this.ॱˋ.ꜟ())) {
                Logger.ˎ("DetailVanAttendGeneralCard", "condictionList is empty.");
                return;
            }
            ˏ(this.ॱˋ);
            ˊ(this.ॱˋ);
            return;
        }
        Logger.ˎ("DetailVanAttendGeneralCard", "invalid data");
    }

    private void ˏ(DetailVanAttendcardBean detailVanAttendcardBean) {
        if (this.ˋ == null) {
            Logger.ˎ("DetailVanAttendGeneralCard", "rootview is null");
            return;
        }
        ((TextView) this.ˋ.findViewById(j.ʻـ)).setText(detailVanAttendcardBean.ॱ());
        ((TextView) this.ˋ.findViewById(j.ʻᐧ)).setText(detailVanAttendcardBean.ㆍ());
    }

    private void ˊ(DetailVanAttendcardBean detailVanAttendcardBean) {
        ॱ(detailVanAttendcardBean);
        ʻ();
        ˋ(detailVanAttendcardBean);
    }

    private void ˎ() {
        this.ᐝ = this.ˋ.findViewById(j.ʻʾ);
        TextView textView = (TextView) this.ᐝ.findViewById(j.ॱᵕ);
        String string = this.ʻ.getString(n.ʴ);
        CharSequence spannableString = new SpannableString(this.ʻ.getString(n.ʻʼ, new Object[]{string}));
        int indexOf = spannableString.toString().indexOf(string);
        ckl o_ckl = new ckl(this.ʻ);
        o_ckl.ˏ(new eit(this.ʻ));
        spannableString.setSpan(o_ckl, indexOf, string.length() + indexOf, 33);
        spannableString.setSpan(new ForegroundColorSpan(this.ʻ.getResources().getColor(c.ʽ)), indexOf, string.length() + indexOf, 33);
        spannableString.setSpan(new TypefaceSpan(this.ʻ.getResources().getString(n.ॱˎ)), indexOf, string.length() + indexOf, 33);
        textView.setText(spannableString);
        textView.setMovementMethod(new ckl.c());
        textView.setHighlightColor(this.ʻ.getResources().getColor(c.ˉ));
    }

    private void ˊ() {
        this.ʼ = (LinearLayout) this.ˋ.findViewById(j.ᴸ);
        this.ˊॱ = (ImageView) this.ˋ.findViewById(j.ᴵˋ);
        this.ॱॱ = this.ˋ.findViewById(j.ᵀ);
        this.ʽ = this.ˋ.findViewById(j.ꜟʼ);
        this.ˏॱ = (ImageView) this.ˋ.findViewById(j.ꜞʼ);
        this.ˋॱ = (ImageView) this.ˋ.findViewById(j.ꓹॱ);
        this.ͺ = (ImageView) this.ˋ.findViewById(j.ᵎˎ);
        this.ॱˊ = (ImageView) this.ˋ.findViewById(j.ꜞʽ);
        this.ᐝॱ = (ImageView) this.ˋ.findViewById(j.ꓸʻ);
        this.ॱˎ = (HwButton) this.ˋ.findViewById(j.ʻʿ);
        this.ॱˎ.setOnClickListener(this);
        this.ʻॱ = (HwButton) this.ˋ.findViewById(j.ʻˌ);
        this.ʻॱ.setOnClickListener(this);
    }

    private void ॱॱ() {
        this.ˑ = this.ˋ.findViewById(j.ʻˑ);
        this.ˎˏ = (TextView) this.ˋ.findViewById(j.ʲ);
        this.ˏˎ = (TextView) this.ˋ.findViewById(j.ʼʽ);
        this.ˏˏ = this.ˋ.findViewById(j.ʻˈ);
        this.ॱͺ = (TextView) this.ˋ.findViewById(j.ʽʼ);
    }

    private void ॱ(DetailVanAttendcardBean detailVanAttendcardBean) {
        List<CondictionBean> ꜟ = detailVanAttendcardBean.ꜟ();
        if (ꜟ == null || ꜟ.size() < 2) {
            Logger.ˋ("DetailVanAttendGeneralCard", "invalid conditionList");
            return;
        }
        for (CondictionBean condictionBean : ꜟ) {
            if (condictionBean == null) {
                Logger.ˎ("DetailVanAttendGeneralCard", "condictionBean is null");
            } else if (condictionBean.ˊ() == 0) {
                this.ॱᐝ = condictionBean;
            } else if (condictionBean.ˊ() == 1) {
                this.ˋᐝ = condictionBean;
            } else if (condictionBean.ˊ() == 2) {
                this.ˍ = condictionBean;
            } else {
                Logger.ˎ("DetailVanAttendGeneralCard", "invalid type:" + condictionBean.ˊ());
            }
        }
        ˊ(this.ॱᐝ);
        ॱ(this.ˋᐝ);
        ˋ(this.ˍ);
    }

    private void ˊ(CondictionBean condictionBean) {
        if (condictionBean == null) {
            this.ˎˎ = false;
            if (this.ˋˋ == 0) {
                this.ˋˋ = 1;
            }
            Logger.ˎ("DetailVanAttendGeneralCard", "order condiction is null");
            this.ʼ.setVisibility(8);
            this.ॱॱ.setVisibility(8);
            this.ʽ.setBackground(null);
            return;
        }
        this.ˎˎ = true;
        Logger.ˎ("DetailVanAttendGeneralCard", "setOrderView:" + condictionBean.ॱ());
        this.ʼ.setVisibility(0);
        this.ॱॱ.setVisibility(0);
        this.ʽ.setBackgroundResource(c.ˏ);
        TextView textView = (TextView) this.ˋ.findViewById(j.ᴶ);
        ((TextView) this.ˋ.findViewById(j.ᵋ)).setText(condictionBean.ˎ());
        textView.setText(condictionBean.ॱॱ());
        int ॱ = condictionBean.ॱ();
        if (ॱ == 1) {
            this.ˋˋ = 1;
        }
        ˎ(ॱ);
    }

    private void ˎ(int i) {
        if (!UserSession.getInstance().isLoginSuccessful()) {
            this.ˊॱ.setBackgroundResource(o.ewm.e.ʻˋ);
            this.ॱˎ.setVisibility(8);
            this.ͺ.setVisibility(8);
        } else if (this.ˋˋ > 0) {
            this.ˊॱ.setBackgroundResource(o.ewm.e.ʻᐝ);
            this.ॱˎ.setVisibility(8);
            this.ͺ.setVisibility(0);
            this.ͺ.setBackgroundResource(o.ewm.e.ꞌ);
        } else if (i != 0) {
            this.ˊॱ.setBackgroundResource(o.ewm.e.ʻᐝ);
            this.ॱˎ.setVisibility(8);
            this.ͺ.setVisibility(0);
            this.ͺ.setBackgroundResource(o.ewm.e.ꞌ);
            this.ˋˋ = 1;
            ˊ(0);
        } else if (this.ˌ == 1) {
            this.ˊॱ.setBackgroundResource(o.ewm.e.ʻˋ);
            this.ॱˎ.setVisibility(8);
            this.ͺ.setVisibility(0);
            this.ͺ.setBackgroundResource(o.ewm.e.ʹ);
        } else {
            this.ˊॱ.setBackgroundResource(o.ewm.e.ʻˋ);
            this.ॱˎ.setVisibility(0);
            this.ͺ.setVisibility(8);
        }
    }

    private void ॱ(CondictionBean condictionBean) {
        if (condictionBean == null) {
            Logger.ˎ("DetailVanAttendGeneralCard", "question condiction is null");
            return;
        }
        Logger.ˎ("DetailVanAttendGeneralCard", "setQuestionView:" + condictionBean.ॱ());
        TextView textView = (TextView) this.ˋ.findViewById(j.ꜛ);
        ((TextView) this.ˋ.findViewById(j.ꜞʻ)).setText(condictionBean.ˎ());
        textView.setText(condictionBean.ॱॱ());
        int ॱ = condictionBean.ॱ();
        if (ॱ == 1) {
            this.ˋˋ = 2;
        }
        ˊ(ॱ);
    }

    private void ˊ(int i) {
        if (!UserSession.getInstance().isLoginSuccessful()) {
            if (this.ˎˎ) {
                this.ˏॱ.setBackgroundResource(o.ewm.e.ʼˋ);
            } else {
                this.ˏॱ.setBackgroundResource(o.ewm.e.ʻˋ);
            }
            this.ʻॱ.setVisibility(8);
            this.ॱˊ.setVisibility(8);
        } else if (this.ˋˋ == 0) {
            this.ˏॱ.setBackgroundResource(o.ewm.e.ʼˋ);
            this.ʻॱ.setVisibility(8);
            this.ॱˊ.setVisibility(8);
        } else if (this.ˋˋ >= 2) {
            this.ˏॱ.setBackgroundResource(o.ewm.e.ʻᐝ);
            this.ʻॱ.setVisibility(8);
            this.ॱˊ.setVisibility(0);
            this.ॱˊ.setBackgroundResource(o.ewm.e.ꞌ);
        } else if (this.ˋˋ != 1) {
            Logger.ˎ("DetailVanAttendGeneralCard", "invalid step:" + this.ˋˋ);
        } else if (i != 0) {
            this.ˏॱ.setBackgroundResource(o.ewm.e.ʻᐝ);
            this.ʻॱ.setVisibility(8);
            this.ॱˊ.setVisibility(0);
            this.ॱˊ.setBackgroundResource(o.ewm.e.ꞌ);
            this.ˋˋ = 2;
            ˋ(0);
        } else if (this.ˌ == 1) {
            this.ˏॱ.setBackgroundResource(o.ewm.e.ʻˋ);
            this.ʻॱ.setVisibility(8);
            this.ॱˊ.setVisibility(0);
            this.ॱˊ.setBackgroundResource(o.ewm.e.ʹ);
        } else {
            this.ˏॱ.setBackgroundResource(o.ewm.e.ʻˋ);
            this.ʻॱ.setVisibility(0);
            this.ॱˊ.setVisibility(8);
        }
    }

    private void ˋ(CondictionBean condictionBean) {
        if (condictionBean == null) {
            Logger.ˎ("DetailVanAttendGeneralCard", "publish condiction is null");
            return;
        }
        Logger.ˎ("DetailVanAttendGeneralCard", "setPublishView:" + condictionBean.ॱ());
        ((TextView) this.ˋ.findViewById(j.ꓸʽ)).setText(condictionBean.ˎ());
        int ॱ = condictionBean.ॱ();
        if (ॱ == 1) {
            this.ˋˋ = 3;
        }
        ˋ(ॱ);
    }

    private void ˋ(int i) {
        if (!UserSession.getInstance().isLoginSuccessful()) {
            this.ˋॱ.setBackgroundResource(o.ewm.e.ʼˋ);
            this.ᐝॱ.setVisibility(8);
        } else if (this.ˋˋ < 2) {
            this.ˋॱ.setBackgroundResource(o.ewm.e.ʼˋ);
            this.ᐝॱ.setVisibility(8);
        } else if (i == 0) {
            this.ˋॱ.setBackgroundResource(o.ewm.e.ʻˋ);
            this.ᐝॱ.setVisibility(8);
            ᐝ();
        } else if (i == 1) {
            this.ˋॱ.setBackgroundResource(o.ewm.e.ʻˋ);
            this.ᐝॱ.setVisibility(0);
            this.ᐝॱ.setBackgroundResource(o.ewm.e.ꞌ);
        }
    }

    private void ʻ() {
        ˊ(!UserSession.getInstance().isLoginSuccessful());
    }

    private void ˊ(boolean z) {
        this.ᐝ.setVisibility(z ? 0 : 8);
    }

    private void ˋ(DetailVanAttendcardBean detailVanAttendcardBean) {
        if (detailVanAttendcardBean == null) {
            Logger.ˎ("DetailVanAttendGeneralCard", "setResultView cardbean is null");
            this.ˑ.setVisibility(8);
            this.ˏˏ.setVisibility(8);
            return;
        }
        ᐝ();
    }

    private void ᐝ() {
        if (this.ॱˋ == null) {
            Logger.ˎ("DetailVanAttendGeneralCard", "setResultView cardbean is null");
            this.ˑ.setVisibility(8);
            this.ˏˏ.setVisibility(8);
        } else if (!UserSession.getInstance().isLoginSuccessful()) {
            this.ˑ.setVisibility(8);
            this.ˏˏ.setVisibility(8);
        } else if (this.ˌ != 0) {
            CharSequence ˊ = this.ॱˋ.ˊ();
            CharSequence ʽ = this.ॱˋ.ʽ();
            if (TextUtils.isEmpty(ˊ)) {
                Logger.ˎ("DetailVanAttendGeneralCard", "result title is empty");
                this.ˑ.setVisibility(8);
                this.ˏˏ.setVisibility(8);
            } else if (TextUtils.isEmpty(ʽ)) {
                this.ˑ.setVisibility(0);
                this.ˎˏ.setText(ˊ);
                this.ˏˏ.setVisibility(8);
            } else {
                this.ˑ.setVisibility(8);
                this.ˏˏ.setVisibility(0);
                this.ॱͺ.setText(ˊ);
                this.ˏˎ.setText(ʽ);
                this.ˏˎ.getPaint().setFlags(8);
                this.ˏˎ.getPaint().setAntiAlias(true);
            }
        } else if (this.ˋˋ == 2) {
            this.ˑ.setVisibility(0);
            this.ˎˏ.setText(n.ʹॱ);
            this.ˏˏ.setVisibility(8);
        } else {
            Logger.ˎ("DetailVanAttendGeneralCard", "activity doing, not publish step, should not show result");
            this.ˑ.setVisibility(8);
            this.ˏˏ.setVisibility(8);
        }
    }

    public void ˋ() {
        Logger.ˎ("DetailVanAttendGeneralCard", "onLoginFailed");
    }

    public void onClick(View view) {
        if (this.ॱˋ == null) {
            Logger.ˎ("DetailVanAttendGeneralCard", "invalid cardbean");
            return;
        }
        String userId = UserSession.getInstance().getUserId();
        if (view.getId() == j.ʻʿ) {
            if (this.ॱᐝ == null) {
                Logger.ˎ("DetailVanAttendGeneralCard", "onclick, orderCondiction is null");
                return;
            }
            Object ˋ = this.ॱᐝ.ˋ();
            if (TextUtils.isEmpty(ˋ)) {
                Logger.ˎ("DetailVanAttendGeneralCard", "onclick, order pkgname is empty");
                return;
            }
            efb.ॱ().ˋ(this.ʻ, ˋ, null, this);
            dgh.ॱ(this.ʻ, "091106", "01|" + userId + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + this.ॱˋ.ͺˏ());
        } else if (view.getId() == j.ʻˌ) {
            ʼ();
            dgh.ॱ(this.ʻ, "091206", "01|" + userId + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + this.ॱˋ.ͺˏ());
        } else {
            Logger.ˎ("DetailVanAttendGeneralCard", "invalid click");
        }
    }

    private void ʼ() {
        if (this.ʻ == null) {
            Logger.ˎ("DetailVanAttendGeneralCard", "context == null");
        } else if (!doo.ˊ(this.ʻ)) {
            Logger.ˎ("DetailVanAttendGeneralCard", "no active network");
            evk.ˏ(this.ʻ, n.ʹˊ, 0).ˋ();
        } else if (!UserSession.getInstance().isLoginSuccessful()) {
            eod.ॱ(this.ʻ);
        } else if (this.ˋᐝ == null || TextUtils.isEmpty(this.ˋᐝ.ˏ())) {
            Logger.ˎ("DetailVanAttendGeneralCard", "invalid url");
        } else {
            emz.ॱ(this.ʻ, "internal_webview", this.ˋᐝ.ˏ());
        }
    }

    public void ˎ(BaseRequest o_cvu, ResponseBean responseBean) {
        if ((responseBean instanceof ReserveResponse) && (o_cvu instanceof efc)) {
            ReserveResponse reserveResponse = (ReserveResponse) responseBean;
            efc o_efc = (efc) o_cvu;
            String ˋ = reserveResponse.ˋ();
            String ˋ2 = o_efc.ˋ();
            if (TextUtils.isEmpty(ˋ) || !ˋ.equals(ˋ2) || reserveResponse.getResponseCode() != 0) {
                return;
            }
            if (reserveResponse.getRtnCode_() == 101004 || reserveResponse.getRtnCode_() == 101001) {
                evk.ॱ(NetWorkUtil.getWifiResId(this.ʻ, n.יˏ), 0).ˋ();
                ˎ(ˋ);
            }
        }
    }

    public void ˎ(String str) {
        if (!this.ˎˎ || this.ˋˋ != 0) {
            return;
        }
        if (this.ॱᐝ == null || this.ˋᐝ == null) {
            Logger.ˎ("DetailVanAttendGeneralCard", "orderCondiction == null or questionCondiction == null");
        } else if (TextUtils.isEmpty(str) || !str.equals(this.ॱᐝ.ˋ())) {
            Logger.ˎ("DetailVanAttendGeneralCard", "package name not equal");
        } else {
            this.ͺॱ.post(new e());
        }
    }

    public void ˋ(String str, String str2) {
        if (this.ˋˋ == 1) {
            if (TextUtils.isEmpty(str) || !str.equals(UserSession.getInstance().getUserId())) {
                Logger.ˎ("DetailVanAttendGeneralCard", "user not equal");
            } else if (this.ॱˋ == null) {
                Logger.ˎ("DetailVanAttendGeneralCard", "cardBean == null");
            } else if (TextUtils.isEmpty(str2) || !str2.equals(this.ॱˋ.ᶥ())) {
                Logger.ˎ("DetailVanAttendGeneralCard", "package name not equal :" + str2);
            } else {
                dgh.ॱ(this.ʻ, "091306", "01|" + str + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + this.ॱˋ.ͺˏ());
                this.ͺॱ.post(new a());
            }
        }
    }
}
